/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-08-12 14:11:36
 * @LastEditors: Clark
 * @LastEditTime: 2023-08-12 15:16:09
 * @Description: file content
 */

#include "s3c2440_soc.h"

void delay(volatile int d)
{
    while (d--);
}

int main(void)
{
    int val1 = 0;
    int val2 = 0;

    // 设置GPFCON让GPF4/5/6配置为输出引脚
    GPFCON &= ~((3<<8) | (3<<10) | (3<<12));
    GPFCON |= ((1<<8) | (1<<10) | (1<<12));

    // 配置3个按键引脚输入引脚：GPF0(S2) GPF2(S3) GPF3(S4)
    GPFCON &= ~((3<<0) | (3<<4));               // GPF0,2
    GPFCON |= ((1<<8) | (1<<10) | (1<<12));     // GPG3

    while (1)
    {
        val1 = GPFDAT;
        val2 = GPGDAT;

        if (val1 & (1<<0))          // s2 --> GPF6
        {
            // 松开
            GPFDAT |= (1<<6);
        }
        else
        {
            // 按下
            GPFDAT &= ~(1<<6);
        }

        if (val1 & (1<<2))          // s3 --> GPF5
        {
            GPFDAT |= (1<<5);
        }
        else
        {
            GPFDAT &= ~(1<<5);
        }

        if (val2 & (1<<3))          // s4 --> GPF4
        {
            GPFDAT |= (1<<4);
        }
        else
        {
            GPFDAT &= ~(1<<4);
        }
    }

    return 0;
}
